package com.scau.controller;

import com.scau.dao.StudentDao;
import com.scau.dao.VideoDao;
import com.scau.dao.Impl.StudentDaoImpl;
import com.scau.dao.Impl.VideoDaoImpl;
import com.scau.mapper.SectionMapper;
import com.scau.mapper.StudentMapper;
import com.scau.pojo.Section;
import com.scau.pojo.Student;
import com.scau.pojo.Video;
import com.scau.util.SqlSessionFactoryUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class Test {
	
	@RequestMapping("/testSection")
    public  int testSection(){
        SqlSession session = SqlSessionFactoryUtil.getSession();
        SectionMapper sectionMapper=session.getMapper(SectionMapper.class);
        Section section=new Section();
        section.setSeName("111");
        section.setSePpt("111");
        section.setSeSeq(1);
        section.settId(3);
        
		return sectionMapper.insert(section);
    }
	@RequestMapping("/testStu")
    public  String testStudent(){
        SqlSession session = SqlSessionFactoryUtil.getSession();
        StudentDao studentdao=new StudentDaoImpl();
        Student student=new Student();
//        student.setStGrade("2011");
//		student.setStMajor("2011");
//		student.setStName("2011");
//		student.setStPassword("2011");
//		student.setStSchool("2011");
//		student.setStSex("2011");
//		student.setStTel("2011");
//		student.setStValidation(1);
//		student.setStTest(1);
        Map<String,Object> result=studentdao.getStudentByName("111");
		if((int)result.get("returnCode")==1){
			student=(Student)result.get("student");
			return student.getStSchool();
		}else{
			return "用户不存在！";
		}
        
    }
	@RequestMapping("/testVideo")
    public  String testVideo(){
        SqlSession session = SqlSessionFactoryUtil.getSession();
        VideoDao videodao=new VideoDaoImpl();
        List<Video> video=videodao.query(6); 
        int count=videodao.countBySeId(6);
        for(Video v:video){
        	System.out.println(v.getvName());
        }
        System.out.println(count);
		return "success";
    }
	
}
